برنامه بانک اطلاعاتی sql 2008.
این برنامه اطلاعات یک گروه را در یافت کرده و آن را در بانک اطلاعاتی ذخیره میکند.
با قابلیت گزارش گیری از بانک.
نمایش پیش فاکتور و چاپ فا کتور.
تصاویری از محیط نرم افزار :
فرم مدیریت چاپ فاکتور :
نمونه فاکتور :
***************************************************************
کد های برنامه :
کد فرم اصلی :
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace mesal2
{
public partial class Form1 : Form
{
static public string con = @"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database1.mdf;Integrated Security=True;User Instance=True";
SqlConnection cnn = new SqlConnection(Form1.con);
int cod = 0;
public Form1()
{
InitializeComponent();
}
private void button6_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void Form1_Load(object sender, EventArgs e)
{
cnn.Open();
SqlCommand cmd = new SqlCommand();
cmd.Connection = cnn;
cmd.CommandText = "SELECT * FROM tb_grop";
SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = cmd;
DataTable dt = new DataTable();
da.Fill(dt);
dataGridView1.DataSource = dt;
cnn.Close();
}
private void button1_Click(object sender, EventArgs e)
{
frmadd ad = new frmadd();
ad.ShowDialog();
Form1_Load(null, null);
}
private void button5_Click(object sender, EventArgs e)
{
cnn.Open();
SqlCommand cmd = new SqlCommand();
cmd.Connection = cnn;
cmd.CommandText = "SELECT * FROM tb_grop";
SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = cmd;
DataTable dt = new DataTable();
da.Fill(dt);
dataGridView1.DataSource = dt;
cnn.Close();
FMessegeBox.FarsiMessegeBox.Show(" تعداد گرو ها برابر است با :\r\n"
+ dt.Rows.Count + " عدد", "تعداد گروه ها",
FMessegeBox.FMessegeBoxButtons.Ok, FMessegeBox.FMessegeBoxIcons.Information);
}
private void dataGridView1_DoubleClick(object sender, EventArgs e)
{
try
{
frmedit ed = new frmedit();
ed.txtcod.Text = dataGridView1.CurrentRow.Cells["ID"].Value.ToString();
ed.txtname.Text = dataGridView1.CurrentRow.Cells["Nameg"].Value.ToString();
ed.txtinformatin.Text = dataGridView1.CurrentRow.Cells["information"].Value.ToString();
ed.ShowDialog();
Form1_Load(null, null);
}
catch
{
}
}
private void button3_Click(object sender, EventArgs e)
{
try
{
DialogResult dr;
dr = FMessegeBox.FarsiMessegeBox.Show("آیا گروه انتخاب شده را حذف می کنید ؟", "مدیریت", FMessegeBox.FMessegeBoxButtons.YesNo, FMessegeBox.FMessegeBoxIcons.Question);
if (dr == System.Windows.Forms.DialogResult.Yes)
{
cnn.Open();
SqlCommand cmd = new SqlCommand();
cmd.Connection = cnn;
string sql = "delete FROM tb_grop WHERE id = {0}";
sql = string.Format(sql, cod);
cmd.CommandText = sql;
cmd.ExecuteNonQuery();
cnn.Close();
FMessegeBox.FarsiMessegeBox.Show("گرو حذف شد", "پیام", FMessegeBox.FMessegeBoxButtons.Ok, FMessegeBox.FMessegeBoxIcons.Information);
Form1_Load(null, null);
}
else { return; }
}
catch
{
}
}
private void dataGridView1_Click(object sender, EventArgs e)
{
try
{
cod = Convert.ToInt32(dataGridView1.CurrentRow.Cells["ID"].Value.ToString());
}
catch
{
}
}
private void button4_Click(object sender, EventArgs e)
{
frmreport r = new frmreport();
r.ShowDialog();
}
}
}
کد فرم اضافه کردن گروه :
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace mesal2
{
public partial class frmadd : Form
{
SqlConnection cnn = new SqlConnection(Form1.con);
public frmadd()
{
InitializeComponent();
}
private void btnclose_Click(object sender, EventArgs e)
{
this.Close();
}
private void btnok_Click(object sender, EventArgs e)
{
try
{
if (txtname.Text == "")
{
errorProvider1.SetError(txtname, "نام گروه را وارد کنید");
}
else if (txtinformatin.Text == "" )
{
errorProvider1.Clear();
errorProvider1.SetError(txtinformatin, "توضیحات گروه را وارد کنید");
}
else
{
errorProvider1.Clear();
cnn.Open();
SqlCommand cmd = new SqlCommand();
cmd.Connection = cnn;
string sql = "insert into tb_grop(name,information) values ('{0}','{1}')";
sql = string.Format(sql, txtname.Text, txtinformatin.Text);
cmd.CommandText = sql;
cmd.ExecuteNonQuery();
cnn.Close();
FMessegeBox.FarsiMessegeBox.Show("گرو ثبت شد", "پیام", FMessegeBox.FMessegeBoxButtons.Ok, FMessegeBox.FMessegeBoxIcons.Information);
this.Close();
}
}
catch
{
FMessegeBox.FarsiMessegeBox.Show("گرو ثبت نشد", "پیام", FMessegeBox.FMessegeBoxButtons.Ok, FMessegeBox.FMessegeBoxIcons.Exclamtion);
}
}
private void panelEx1_Click(object sender, EventArgs e)
{
}
}
}
کد فرم ویرایش :
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace mesal2
{
public partial class frmedit : Form
{
SqlConnection cnn = new SqlConnection(Form1.con);
public frmedit()
{
InitializeComponent();
}
private void btnclose_Click(object sender, EventArgs e)
{
this.Close();
}
private void btnok_Click(object sender, EventArgs e)
{
try
{
if (txtname.Text == "")
{
errorProvider1.SetError(txtname, "نام را وارد نکردی");
}
else if (txtinformatin.Text == "")
{
errorProvider1.Clear();
errorProvider1.SetError(txtinformatin, "توضیحات را وارد نکردید");
}
else
{
cnn.Open();
SqlCommand cmd = new SqlCommand();
cmd.Connection = cnn;
string sql = "UPDATE tb_grop SET name = N'{0}' , information = N'{1}' WHERE id = {2}";
sql = string.Format(sql, txtname.Text, txtinformatin.Text,Convert.ToInt32(txtcod.Text));
cmd.CommandText = sql;
cmd.ExecuteNonQuery();
cnn.Close();
FMessegeBox.FarsiMessegeBox.Show("گرو ,یرایش شد", "پیام", FMessegeBox.FMessegeBoxButtons.Ok, FMessegeBox.FMessegeBoxIcons.Information);
this.Close();
}
}
catch
{
}
}
private void panelEx1_Click(object sender, EventArgs e)
{
}
}
}
کد فرم گزارش :
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace mesal2
{
public partial class frmreport : Form
{
SqlConnection cnn = new SqlConnection(Form1.con);
public frmreport()
{
InitializeComponent();
}
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
this.Close();
}
private void button1_Click(object sender, EventArgs e)
{
cnn.Open();
SqlCommand cmd = new SqlCommand();
cmd.Connection = cnn;
cmd.CommandText = "SELECT * FROM tb_grop";
SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = cmd;
DataTable dt = new DataTable();
da.Fill(dt);
stiReport1.Load(@"report\list.mrt");
stiReport1.RegData(dt);
stiReport1.Show();
cnn.Close();
}
private void button2_Click(object sender, EventArgs e)
{
cnn.Open();
SqlCommand cmd = new SqlCommand();
cmd.Connection = cnn;
cmd.CommandText = "SELECT * FROM tb_grop";
SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = cmd;
DataTable dt = new DataTable();
da.Fill(dt);
stiReport1.Load(@"report\list.mrt");
stiReport1.RegData(dt);
stiReport1.Print();
cnn.Close();
}
}
}
**************************************************************************************************
برای دانلود از لینک زیر استفاده کنید.